<?php

class Model_FwUser extends Zend_Db_Table_Abstract
{
	protected $_name = 'fwuser';
	protected $_primary = 'id';
	protected $_sequence = true;
	
	public function getAll()
	{
		$row = $this->fetchAll();
		if(!$row) {
			throw new Exception("Could not fetch records.");
		}
		return $row->toArray();
	}
	
	public function getRow($id)
	{
		$id = (int)$id;
		$row = $this->fetchRow('id = ' . $id);
		if (!$row) {
			throw new Exception("Count not find row $id.");
		}
		return $row->toArray();
	}
	
	public function addRow($data)
	{
		$row = $this->createRow($data);
		$row->save();
	}
	
	public function updateRow($id, $data)
	{
		$id = (int)$id;
		$where = 'id = '.$id;
		$row = $this->update($data, $where);
	}
	
	public function deleteRow($id)
	{
		$id = (int)$id;
		$where = 'id = '.$id;
		$row = $this->delete($where);
	}
}